home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Original Shareware 1.1
/
The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso
/
25
/
lzhc.zip
/
LZHC.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1989-04-17
|
4KB
|
164 lines
PROGRAM LHZConvert;
{ (c)1989 CollisionWare Premium SoftWare, written by Kito Mann }
{ Uses CWARE unit which will soon be avaailable <maybe under different name> }
{ Modify this program as you wish, but PLEASE, keep it within the bounderies }
{ of being able to Exec() PKZIP, etc with only 256k. It was written to be as }
{ small as possible. And please, if you modify this for the public use, send }
{ me a copy. }
{ Collision Theory PM-BBS 10PM-7AM (703)425-4674 }
{$M 9000,0,0}
Uses Dos,
Cware;
Var
PKUNPAK,
PKUNZIP,
PAK,
LHARC,
WORKDIR: String[80];
d,s,s2,s3:string[80];
Dir: DirStr;
FileExt: ExtStr;
FileName: NameStr;
FilePath: PathStr;
f,f2:file of byte;
fz,fz2:longint;
pakb,arcb,zipb:boolean;
x,i,z,k:integer;
ErrorCode : byte;
SRec: SearchRec;
Delfile: boolean;
t: text;
Procedure Parse;
begin
s:=ParamStr(1);
d:=ParamStr(2);
for i:=1 to length(s) do
s[i]:=UpCase(s[i]);
d[1]:=UpCase(d[1]);
if d='D' then delfile:=false;
If (s='') then begin
writeln('Usage: LZHC [path] [D]');
writeln;
writeln('Examples: LZHC c:\dl\*.*');
writeln(' LZHC c:\utils\blah.arc');
writeln;
writeln('[path] is the path and filename to be converted (can be wildcards)');
writeln('[D] means do NOT delete the original file.');
Halt;
end;
FSplit(s,dir,filename,fileext);
end;
Procedure Done(error:boolean);
begin
writeln;
writeln('Thanks for using LZHConvert!');
if error then
writeln('0 files converted, no work to be done!');
halt;
end;
Function ValidExt: boolean;
var b:boolean;
begin
b:=false;
FSplit(filepath,dir,filename,fileext);
s2:=fileext;
if (s2='.ARC') or (s2='.PAK') or (s2='.ZIP') then b:=true;
if s2='.ARC' then arcb:=true;
if s2='.PAK' then pakb:=true;
if s2='.ZIP' then zipb:=true;
ValidExt:=b;
end;
Procedure Convert;
begin
x:=0;
FSplit(filepath,dir,filename,fileext);
fz:=Srec.Size;
writeln;
writeln('File Name: ',dir+filename+fileext);
writeln('File Size: ',fz,' bytes');
writeln;
{$I-} mkdir(workdir) {$I+};
writeln('Unarcing file to ',workdir);
if pakb then
Exec(PAK,' x '+dir+filename+fileext+' '+workdir);
if zipb then
Exec(PKUNZIP,' '+dir+filename+fileext+' '+workdir);
if arcb then
Exec(PKUNPAK,' '+dir+filename+fileext+' '+workdir);
i:=DosError;
if not (i=0) then Done(true);
writeln;
writeln('Freezing file(s) to original directory.');
Exec(LHARC,' a '+dir+filename+' '+workdir+'\*.*');
writeln;
writeln('Removing work directory and deleting files in it.');
writeln;
DeleteDir(workdir);
writeln;
if delfile then begin
writeln('Deleting original file: ',dir+filename+fileext);
assign(f,dir+filename+fileext);
{$I-} erase(f); {$I+};
end;
assign(f2,dir+filename+'.LZH');
reset(f2);
writeln('Original File Size : ',fz,' bytes');
fz2:=filesize(f2);
writeln('New File Size : ',fz2,' bytes');
writeln('Bytes Saved : ',fz-fz2,' bytes');
close(f2);
end;
Procedure ConvertFiles;
begin
FindFirst(s,0,Srec);
while DosError=0 do begin
filepath:=dir+srec.name;
if ValidExt then Convert;
FindNext(Srec);
end;
end;
procedure readdata;
var x:integer;
begin
assign(t,'LZHC.DAT');
{$I-} reset(t) {$I+};
if ioresult <> 0 then
begin
writeln('Can''t find configuration file "LZHC.DAT"');
done(true);
end;
for x:=1 to 7 do readln(t);
readln(t,PKUNPAK);
readln(t,PKUNZIP);
readln(t,PAK);
readln(t,LHARC);
readln(t,WORKDIR);
close(t);
end;
begin
pakb:=false;
arcb:=false;
zipb:=false;
delfile:=true;
writeln('LZHConvert v1.0 - Converts ARC/PAK/ZIP files to LHARC format.');
writeln('(c)1989 CollisionWare(tm) Premium SoftWare, written by Kito Mann.');
writeln('Collision Theory(tm) pm-BBS 10pm-7am (703)425-4674');
writeln;
Parse;
ReadData;
ConvertFiles;
Done(false);
end.